Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[result4k] Prevent unintuitively behaving bounds on resultFromCatching from compiling #59

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from

Conversation

MarcusDunn
Copy link
Contributor

This prevents the following code from compiling

resultFromCatching<NotImplementedError, _> {
    throw NotImplementedError("catch me if you can")
}

Unintuitively, this would throw instead of resulting in a Failure<NotImplementedError> as resultFrom would not catch it (it only catches Exceptions)

This would be a breaking change but catching Errors is generally a bad idea anyways.

This prevents the following erronious code from compiling

```kotlin
resultFromCatching<NotImplementedError, _>
```

which would not ever result in a `Failure<NotImplementedError> as `resultFrom` would not catch it

```
@MarcusDunn MarcusDunn changed the title Result from catching fix [result4k] Prevent unintuitively behaving bounds on resultFromCatching from compiling Mar 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant